<?php

$page = "admin ";

include_once("common.php");


gpp_print_header($page, "Set prereqs below.");

// If the user is logged in, we want to send them to the page where
// they can actually use the application.
if(!gpp_is_authenticated())
{
	gpp_redirect("entrance");
}


$acronyms = get_acronyms_for_display();

?>

<script type="text/javascript">


$(function() {
	$("#add_prereq").click(function() {
		//alert($("#numbers0").val());
		$("#course_list").val($("#course_list").val() + " " + $("#numbers0").val()); 
		})
})



$(function() {
	$("#submit_prereqs").click(function() {
		//alert($("#numbers0").val());
		
		$.getJSON("/json_utils.php",{task: 'set_prereqs', data: JSON.stringify({id: $("#numbers-1").val(), course_list: $("#course_list").val()})}, function(j){
      alert(j['message']);
    	
    	})

	})
})

$(function() {
	$("#clear_prereqs").click(function() {
		//alert($("#numbers0").val());
		$("#course_list").val(""); 
		})
})


</script>

<div id="head">

<h2><?php echo $message ?></h2>

</div>
<p>To create a "prerequisite", which would be something like MATH 152 and MATH 133 OR MATH 155, you would do: "152 133, 155". Each item separated by a comma represents a set of classes that fulfill "prerequisite. So you may have to have some classes in there a few times. Keep in mind that this is a course id, not the course number. Use the interface below.</p>

<h3>DO THIS RIGHT OR EVERYTHING WILL BREAK.</h3>

		Choose course to set prerequisites: <select class="acronym" title="-1">

					<?php echo $acronyms; ?>

				</select>
				<select id="numbers-1"></select>
			<br />
								Add prerequisite: <select class="acronym" title="0">
					<?php echo $acronyms; ?>
				</select>
				<select id="numbers0"></select><input type="button" size="1" title="0" value="+" class="add_df" name="add_prereq" id="add_prereq" />
			
			<br />
			
			<input type="text" id="course_list"/>
			<br />
			<input type="button" id="submit_prereqs" value="Overwrite prereqs for this course." /><br /><br />
			<input type="button" id="clear_prereqs" value="Clear" />

</div>
